import request from '@/utils/request';
import { API } from './enumAPI';

// 文件列表
export const reqFileList = (data: any = { data: {} }) => request.post<any, any>(API.FILE_LISTS_URL, data);
// 删除文件
export const deleteFile = (data: any) => request.post<any, any>(API.FILE_DELETE_URL, data);

// 文件分片上传
export const reqUploadFileSplit = (fileFormData: any, fileParams) =>
  request.post<any, any>(
    `${API.FILE_SPLIT_UPLOAD_URL}?fileName=${fileParams?.fileName}&chunkNumber=${fileParams?.chunkNumber}&totalChunks=${fileParams?.totalChunks}&fileType=${fileParams?.fileType}`,
    fileFormData,
    { timeout: 30 * 1000 },
  );

// 添加文件上传记录
export const reqAddFile = (data: any) => request.post<any, any>(API.FILE_ADD_URL, data);

// 下载文件
export const reqDownloadFile = (fileUrl, data?: any) =>
  request.post<any, any>(`${API.FILE_DOWNLOAD_URL}?fileUrl=${fileUrl}`, data, { timeout: 5 * 60 * 1000 });
// 获取所有设备类型
export const reqDeviceAll = () => request.post<any, any>(API.DEVICE_ALL_URL);
// 获取所有产品类型
export const reqProductAll = () => request.get<any, any>(API.PRODUCT_ALL_URL);
